package com.zyh.day02.keyvalue

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object JoinTest {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
      .setAppName("m")
      .setMaster("local[*]")
    val sc = new SparkContext(conf)
    val rdd1 = sc.makeRDD(List(("xps15 9570",57),("Thinkpad X230",257),("联想拯救者R9000",575),("iphoneX",537),("macMini",157)))
    //2. 创建RDD：商品访问量
    val rdd2 = sc.makeRDD(List(("Thinkpad X230",20),("macMini",50),("联想拯救者R9000",30),("xps15 9570",10),("iphoneX",40)))
    val rdd3: RDD[(String, (Int, Int))] = rdd1.join(rdd2)
    rdd3.foreach(println)
    sc.stop()
  }
}
